package com.flysky.dao;

import java.util.HashMap;
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.flysky.dao.finance.IFinanceDao;
import com.flysky.dao.user.IUserDao;
import com.flysky.dao.user.PspTestDao;
import com.flysky.model.HibernateTestModel;
import com.flysky.model.finance.BigTypeHbmModel;
import com.flysky.model.finance.SmallTypeHbmModel;

public class DaoTest {
	public static ApplicationContext ctx = null;
	@BeforeClass
	public static void setUpClass(){
		String[] configLocations = new String[]{
				"/WebContent/WEB-INF/config/servlet-context.xml",
				"/WebContent/WEB-INF/config/applicationContext-service.xml",
				"/WebContent/WEB-INF/config/applicationContext-dao.xml"
		};
		ctx = new FileSystemXmlApplicationContext(configLocations);
	}
	
	//@Test
	public void testUserDao(){
		
		IUserDao userDao = ctx.getBean("userDao", IUserDao.class);
		HashMap<String,Object> param = new HashMap<String,Object>();
		param.put("soeid", "KP18166");
		param.put("role_id", "6");
		param.put("pop_id", "1");
		//UserModel userModel = userDao.findUser(param);
	}
	//@Test
	public void testHibernateDa(){
		PspTestDao testDao = ctx.getBean("testDao", PspTestDao.class);
		HibernateTestModel testModel = new HibernateTestModel();
		testModel.setGoc_code("HKG20130816");
		testDao.save(testModel);
	}
	
	@Test
	public void testFinanceDao(){
		IFinanceDao financeDao= ctx.getBean("financeDao",IFinanceDao.class);
//		List<BigTypeHbmModel> result = financeDao.getAllFinanceBigType();
//		for(BigTypeHbmModel bigType : result){
//			System.out.println(bigType);
//		}
//		System.out.println("汉字");
//		
//		List<SmallTypeHbmModel> result1 = financeDao.getAllFinanceSmallType();
//		for(SmallTypeHbmModel smallType : result1){
//			System.out.println(smallType);
//		}
		HashMap<String,String> param = new HashMap<String,String>();
		param.put("MAKER", "40280381417265c701417303e6020000");
		financeDao.countAllMatchFinances(param);
	}
}
